package helloworld;

import com.lmax.disruptor.RingBuffer;

/**
 * @author ChenJunhong
 * @date 2018/12/19
 * Description:
 */
public class Producer {

    private RingBuffer<Order> ringBuffer;


    public Producer(RingBuffer<Order> ringBuffer) {
        this.ringBuffer = ringBuffer;
    }

    public void sendData(String s) {
        long sequence = ringBuffer.next();
        Order order = ringBuffer.get(sequence);
        order.setId(s);
        ringBuffer.publish(sequence);
    }
}
